﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Data;
using MySqlConnection;

namespace PictureControls
{
    public partial class AddImage : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void save_Click(object sender, EventArgs e)
        {
            int picSize = fileUpload.PostedFile.ContentLength;
            string picType = fileUpload.PostedFile.ContentType;
            byte[] picData = new byte[picSize];
            fileUpload.PostedFile.InputStream.Read(picData, 0, picSize);
            ImageClass img = new ImageClass();

            //VOImage img = new VOImage();
            img.data = picData;
            img.size = picSize;
            img.description = txtDesc.Text;
            img.name = txtTitle.Text;
            img.ext = picType;
            ImageData.InsertImage(img);
            Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri, true);
        }
    }
}